All Questions
48 questions
2votes
1answer
255views
Hackerrank problem -"Another Prime Problem"
I came across this issue in the problem titled: Another Prime Problem. Here's my solution with JavaScript which passed test case-1, but for other test cases it led to timeout. ...
2votes
1answer
926views
Codewars: Prime Streaming (PG-13)
I'm timing out on Codewars' Prime Streaming kata. Below is my code: ...
3votes
1answer
708views
Project Euler #357: Prime generating integers
Project Euler Problem 357 asks: Consider the divisors of 30: 1,2,3,5,6,10,15,30. It can be seen that for every divisor d of 30, $$d+30/d$$ is prime. Find the sum of all positive integers n ...
7votes
1answer
932views
Hackerrank: Computer Game (max-flow problem with integer factorization)
I am working on a coding challenge from the Hackerrank site. Given two equal-length arrays of integers, with values from 2 to 109, find the maximum number of times we can remove a pair (Ai, Bj) where ...
11votes
5answers
3kviews
A faster way to compute the largest prime factor
I am self-learning js and came across this problem(#3) from the Euler Project The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Logic:...
6votes
1answer
257views
Counting primes in a range whose digits are all prime
Codewars Kata: Given integers a and b, count all primes p where a ≤ p < b and the digits of p are all prime. b may be as large as 107. To start with, I hardcoded all valid 1903 primes in \$[1, 10^...
2votes
2answers
336views
Work out largest prime factor of a number
I am trying to get better at problem solving, so I am going through challenges on Project Euler. Problem: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the ...
2votes
2answers
6kviews
The next prime number in Python
I have written a solution to a DM::OJ exercise to find the next Prime Number after a given number (input). I'm seeking to optimize it so that it will run for any number up to ...
2votes
3answers
896views
Kattis prime reduction challenge
I am solving the Prime Reduction challenge on Kattis. Consider the following process, which we’ll call prime reduction. Given an input x: if x is prime, print x and stop factor x into its ...
1vote
2answers
172views
Euler Project #3 Largest prime factor timeout
I have been recently trying my hands on Euler's Project through HackerRank and got stuck with project #3 where you have to find the Largest Prime Factor. Question: The prime factors of 13195 are 5, 7,...
3votes
2answers
235views
Project Euler #7: Nth prime number
I was solving Project Euler #7 on Hackerrank but for two cases, execution time is more than 2 sec. Can you help with optimizing? I'm new to programming. ...
1vote
3answers
1kviews
Display a number as a product of its prime factors
Task: Link to original problem :https://www.spoj.com/problems/FACTCG2/ The task in this problem is to write a number in a multiplication of prime numbers separated by “...
0votes
2answers
227views
Prime number generation - SPOJ
This is a program to generate prime numbers for a given range. The sieve of Eratosthenes algorithm was implemented, but still the SPOJ says time limit exceeded. Where can some optimizations be made? ...
5votes
1answer
1kviews
Prime pair set finder (Project Euler problem 60)
I made a code that can find the prime sets: The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For ...
3votes
1answer
266views
Spoj-Prime Generator
Question- Generate all prime numbers between two given numbers. https://www.spoj.com/problems/PRIME1/ My attempt- I used segmented sieve method. ...